package org.example.ExperimentFour.Second;

import java.io.BufferedReader;
import java.io.FileReader;

public class Main {
    public static void main(String[] args) {
        try {
            // 读取配置文件的位置
            BufferedReader reader = new BufferedReader(new FileReader("E:\\Java\\JavaExperimentOne\\src\\main\\java\\org\\example\\ExperimentFour\\Second\\database.config"));
            String line;
            while ((line = reader.readLine()) != null) {
                String[] parts = line.split("=");
                String databaseName = parts[0].trim();
                System.out.println(databaseName);
//                使用工厂模式创建实例对象
                DataService dataService = DataServiceFactory.createDataService(databaseName);
                // 使用 dataService 调用方法
                dataService.add(new Object());
                dataService.delete(new Object());
                dataService.update(new Object());
            }
            reader.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
